const Service = require('egg').Service;
class WxService extends Service {
    async getJsSDKSign(url) {
        return this.ctx.service.curlService.curlPost('api/v1.0/wx/getJsSDKSign',{
            url:url
        })
    }
    async login(wx_code,ip) {
        return this.ctx.service.curlService.curlPost('api/v1.0/user/mWebWXLogin',{
            wx_code:wx_code,
            ip:ip
        })
    }
    async getMiniProjectQRCode(page,scene) {
        return this.ctx.service.curlService.curlPost('api/v1.0/wx/getMiniProjectQRCode',{
            scene:scene,
            page:page
        })
    }
    async getTempQrCode(scene_str) {
        return this.ctx.service.curlService.curlPost('api/v1.0/wx/getTempQrCode',{
            scene_str:scene_str
        })
    }
    async getQrCode(scene_str) {
        return this.ctx.service.curlService.curlPost('api/v1.0/wx/getQrCode',{
            scene_str:scene_str
        })
    }
    async getWxLoginUrl(app_id,redirect_uri,scope,state){
        let url = 'https://open.weixin.qq.com/connect/oauth2/authorize?'+
            'appid=' + app_id +
            '&redirect_uri=' + encodeURIComponent(redirect_uri) +
            '&response_type=code&scope=' + scope +
            '&state=' + state +
            '#wechat_redirect';
        return url;
    }
}
module.exports = WxService;